package ua.kpi_java_training.tyshchenko.module2;

import java.util.Scanner;

/**
 * Class contains input methods
 *
 * @author Vlad Tyshchenko
 * @version 1.0 30 May 2013
 */
public class Input {

    /**
     * Method gets integers numbers from the console
     *
     * @param message - output to the console
     * @return - integers number
     */
    public static int inputNumber(String message) {
        System.out.println(message);
        Scanner sc = new Scanner(System.in);
        while (!sc.hasNextInt()) {
            System.out.println("Error. " + message);
            sc.next();
        }
        return sc.nextInt();
    }

    /**
     * Method gets positive numbers
     *
     * @param message - output to the console
     * @return positive number
     */
    public static int inputPositiveNumbers(String message) {
        int number;
        number = inputNumber(message);
        while (number <= 0) {
            System.out.println("Wrong number");
            number = inputNumber(message);
        }
        return number;
    }
}
